home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cvs / sprite / RCS / main.c,v < prev    next >
Encoding:
Text File  |  1991-09-10  |  7.2 KB  |  280 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.09.10.16.12.21;  author jhh;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.09.03.13.07.34;  author jhh;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @added info command
  27. @
  28. text
  29. @char rcsid[] = "$Id: main.c,v 1.23 89/11/20 00:06:34 berliner Exp $\nPatch level ###\n";
  30.  
  31. /*
  32.  *    Copyright (c) 1989, Brian Berliner
  33.  *
  34.  *    You may distribute under the terms of the GNU General Public License
  35.  *    as specified in the README file that comes with the CVS 1.0 kit.
  36.  *
  37.  * This is the main C driver for the CVS system.
  38.  *
  39.  * Credit to Dick Grune, Vrije Universiteit, Amsterdam, for writing
  40.  * the shell-script CVS system that this is based on.
  41.  *
  42.  * Usage:
  43.  *    cvs [options] command [options] [files/modules...]
  44.  *
  45.  * Where "command" is composed of:
  46.  *        checkout    Check out a module/dir/file
  47.  *        update        Brings work tree in sync with repository
  48.  *        commit        Checks files into the repository
  49.  *        diff        Runs diffs between revisions
  50.  *        log        Prints to "rlog" information for files
  51.  *        add        Adds an entry to the repository
  52.  *        remove        Removes an entry from the repository
  53.  *        status        Status info on the revisions
  54.  *        join        Merge two RCS revisions
  55.  *        patch        "patch" format diff listing between releases
  56.  *        tag        Add/delete a symbolic tag to the RCS file
  57.  *
  58.  * Future:
  59.  *        checkin        Adds new *directories* to the repository
  60.  *                Currently being done by an external shell
  61.  *                script.
  62.  *
  63.  * Brian Berliner
  64.  * 4/20/89
  65.  */
  66.  
  67. #include <sys/param.h>
  68. #include "cvs.h"
  69. #include "patchlevel.h"
  70.  
  71. char *progname, *command;
  72.  
  73. char *fileargv[MAXFILEPERDIR];
  74. int fileargc;
  75.  
  76. int use_editor = TRUE;
  77. int cvswrite = !CVSREAD_DFLT;
  78. int really_quiet = FALSE;
  79. int quiet = FALSE;
  80. int force_tag_match = FALSE;
  81.  
  82. /*
  83.  * Globals for the lists created in Collect_Sets()
  84.  */
  85. char Clist[MAXLISTLEN], Glist[MAXLISTLEN], Mlist[MAXLISTLEN];
  86. char Olist[MAXLISTLEN], Alist[MAXLISTLEN], Rlist[MAXLISTLEN];
  87. char Wlist[MAXLISTLEN], Llist[MAXLISTLEN], Blist[MAXLISTLEN];
  88. char Dlist[MAXLISTLEN];
  89.  
  90. /*
  91.  * Globals which refer to a particular file
  92.  */
  93. char Repository[MAXPATHLEN];
  94. char User[MAXPATHLEN], Rcs[MAXPATHLEN];
  95. char VN_User[MAXPATHLEN], TS_User[MAXPATHLEN];
  96. char VN_Rcs[MAXPATHLEN], TS_Rcs[MAXPATHLEN];
  97. char Tag[MAXPATHLEN], Date[MAXPATHLEN];
  98.  
  99. /*
  100.  * Options is used to hold options passed on to system(), while prog
  101.  * is alwys used in the calls to system().
  102.  */
  103. char Options[MAXPATHLEN];
  104. char prog[MAXPROGLEN];
  105.  
  106. /*
  107.  * Defaults, for the environment variables that are not set
  108.  */
  109. char *Rcsbin = RCSBIN_DFLT;
  110. char *Editor = EDITOR_DFLT;
  111. char *CVSroot = CVSROOT_DFLT;
  112.  
  113. main(argc, argv)
  114.     int argc;
  115.     char *argv[];
  116. {
  117.     extern char *getenv();
  118.     register char *cp;
  119.     register int c;
  120.     int help = FALSE, err = 0;
  121.  
  122.     /*
  123.      * Just save the last component of the path for error messages
  124.      */
  125.     if ((progname = rindex(argv[0], '/')) == NULL)
  126.     progname = argv[0];
  127.     else
  128.     progname++;
  129.  
  130.     /*
  131.      * Query the environment variables up-front, so that
  132.      * they can be overridden by command line arguments
  133.      */
  134.     if ((cp = getenv(RCSBIN_ENV)) != NULL)
  135.     Rcsbin = cp;
  136.     if ((cp = getenv(EDITOR_ENV)) != NULL)
  137.     Editor = cp;
  138.     if ((cp = getenv(CVSROOT_ENV)) != NULL)
  139.     CVSroot = cp;
  140.     if (getenv(CVSREAD_ENV) != NULL)
  141.     cvswrite = FALSE;
  142.  
  143.     optind = 1;
  144.     while ((c = getopt(argc, argv, "rwvb:e:d:H")) != -1) {
  145.     switch (c) {
  146.     case 'r':
  147.         cvswrite = FALSE;
  148.         break;
  149.     case 'w':
  150.         cvswrite = TRUE;
  151.         break;
  152.     case 'v':
  153.         (void) sprintf(index(rcsid, '#'), "%d\n", PATCHLEVEL);
  154.         (void) fputs(rcsid, stdout);
  155.         (void) fputs("\nCopyright (c) 1989, Brian Berliner\n\n\
  156. CVS may be copied only under the terms of the GNU General Public License,\n\
  157. a copy of which can be found with the CVS 1.0 distribution kit.\n", stdout);
  158.         exit(0);
  159.         break;
  160.     case 'b':
  161.         Rcsbin = optarg;
  162.         break;
  163.     case 'e':
  164.         Editor = optarg;
  165.         break;
  166.     case 'd':
  167.         CVSroot = optarg;
  168.         break;
  169.     case 'H':
  170.         help = TRUE;
  171.         break;
  172.     case '?':
  173.     default:
  174.         usage();
  175.     }
  176.     }
  177.     argc -= optind;
  178.     argv += optind;
  179.     if (argc < 1)
  180.     usage();
  181.  
  182.     /*
  183.      * Specifying just the '-H' flag to the sub-command causes a Usage
  184.      * message to be displayed.
  185.      */
  186.     command = cp = argv[0];
  187.     if (help == TRUE || (argc > 1 && strcmp(argv[1], "-H") == 0))
  188.     argc = -1;
  189.  
  190.     /*
  191.      * Make standard output line buffered, so that progress can be
  192.      * monitored when redirected to a file, but only when we're not
  193.      * running the "patch" command, as it generates lots of output
  194.      * to stdout -- just leave it block buffered.
  195.      */
  196.     if (strcmp(cp, "patch") != 0)
  197.     setlinebuf(stdout);
  198.  
  199.     if (strcmp(cp, "update") == 0)
  200.     err += update(argc, argv);
  201.     else if (strcmp(cp, "commit") == 0 || strcmp(cp, "ci") == 0)
  202.     commit(argc, argv);
  203.     else if (strcmp(cp, "diff") == 0)
  204.     diff(argc, argv);
  205.     else if (strcmp(cp, "checkout") == 0 || strcmp(cp, "co") == 0 ||
  206.         strcmp(cp, "get") == 0)
  207.     checkout(argc, argv);
  208.     else if (strcmp(cp, "log") == 0)
  209.     log(argc, argv);
  210.     else if (strcmp(cp, "status") == 0)
  211.     status(argc, argv);
  212.     else if (strcmp(cp, "add") == 0)
  213.     add(argc, argv);
  214.     else if (strcmp(cp, "remove") == 0)
  215.     remove(argc, argv);
  216.     else if (strcmp(cp, "join") == 0)
  217.     join(argc, argv);
  218.     else if (strcmp(cp, "patch") == 0)
  219.     patch(argc, argv);
  220.     else if (strcmp(cp, "tag") == 0)
  221.     tag(argc, argv);
  222.     else if (strcmp(cp, "info") == 0)
  223.     info(argc, argv);
  224.    else
  225.     usage();            /* oops.. no match */
  226.     Lock_Cleanup(0);
  227.     exit(err);
  228. }
  229.  
  230. static
  231. usage()
  232. {
  233.     (void) fprintf(stderr,
  234.     "Usage: %s [cvs-options] command [command-options] [files...]\n",
  235.            progname);
  236.     (void) fprintf(stderr, "\tWhere 'cvs-options' are:\n");
  237.     (void) fprintf(stderr, "\t\t-r\t\tMake checked-out files read-only\n");
  238.     (void) fprintf(stderr,
  239.     "\t\t-w\t\tMake checked-out files read-write (default)\n");
  240.     (void) fprintf(stderr, "\t\t-v\t\tCVS version and copyright\n");
  241.     (void) fprintf(stderr, "\t\t-b bindir\tFind RCS programs in 'bindir'\n");
  242.     (void) fprintf(stderr,
  243.     "\t\t-e editor\tUse 'editor' for editing log information\n");
  244.     (void) fprintf(stderr, "\t\t-d CVS_root_directory\n");
  245.     (void) fprintf(stderr, "\t\t\t\t\Points to the root of the CVS tree\n");
  246.     (void) fprintf(stderr, "\tand 'command' is:\n");
  247.     (void) fprintf(stderr, "\t\tcheckout\tCreates a new CVS directory\n");
  248.     (void) fprintf(stderr,
  249.     "\t\tupdate\t\tBrings work tree in sync with repository\n");
  250.     (void) fprintf(stderr,
  251.     "\t\tcommit\t\tChecks files into the repository\n");
  252.     (void) fprintf(stderr, "\t\tdiff\t\tRuns diffs between revisions\n");
  253.     (void) fprintf(stderr,
  254.     "\t\tlog\t\tPrints out 'rlog' information for files\n");
  255.     (void) fprintf(stderr, "\t\tstatus\t\tStatus info on the revisions\n");
  256.     (void) fprintf(stderr, "\t\tadd\t\tAdds an entry to the repository\n");
  257.     (void) fprintf(stderr,
  258.     "\t\tremove\t\tRemoves an entry from the repository\n");
  259.     (void) fprintf(stderr,
  260.     "\t\tjoin\t\tJoins an RCS revision with the head on checkout\n");
  261.     (void) fprintf(stderr,
  262.     "\t\tpatch\t\t\"patch\" format diffs between releases\n");
  263.     (void) fprintf(stderr, "\t\ttag\t\tAdd a symbolic tag to the RCS file\n");
  264.     (void) fprintf(stderr,
  265.     "\tSpecify the '-H' option to each command for Usage information\n");
  266.     exit(1);
  267. }
  268. @
  269.  
  270.  
  271. 1.1
  272. log
  273. @Initial revision
  274. @
  275. text
  276. @d194 3
  277. a196 1
  278.     else
  279. @
  280.